What is where did three sheets to the wind come from?

Three sheets to the wind is a nautical phrase that refers to a ship that is out of control due to the wind catching the three lower corner edges of its sails, causing them to flap uncontrollably. The phrase has since taken on a figurative meaning, referring to someone who is drunk or inebriated to the point of being out of control, similar to a ship in that state. The origins of the phrase are believed to date back to the 18th or 19th century and were likely coined by sailors and seamen who often dealt with ships that were three sheets to the wind.